package com.wsc.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.wsc.entity.Student;
import com.wsc.entity.Teacher;

public interface StudentRepository extends JpaRepository<Student, Integer>, JpaSpecificationExecutor<Student> {

	@Modifying
	@Query(value = "update t_students s set s.status = :out where s.cardno = :cardno", nativeQuery = true)
	void OutSwipingCard(String cardno, int out);

	@Modifying
	@Query(value = "update t_students s set s.status = :status where s.cardno = :cardno", nativeQuery = true)
	Integer swipingCard(String cardno, Integer status);

	// 通过卡号找学生
	Student findByCardno(@Param("cardno") String cardno);

	// 定时修改未刷卡离开的状态
	@Modifying
	@Query(nativeQuery = true, value = ("update t_students set status=:status  where id =:id"))
	void updateStatus(@Param("id") Integer id, @Param("status") Integer status);
	/***
	 * 修改status为0
	 */
	@Modifying
	@Query(nativeQuery = true,value = "update t_students set status = 0")
	void updateAllStatusToZero();

}
